﻿@model BlogPostListModel
@using Nop.Web.Extensions;
@using Nop.Web.Models.Blogs;
@{
    Layout = "~/Views/Shared/_Root.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.Blog").Text);
}
<div class="page blog-page">
    <div class="page-title">
        <h1>
            @if (String.IsNullOrEmpty(Model.PagingFilteringContext.Tag))
            {
                if (Model.PagingFilteringContext.GetParsedMonth().HasValue)
                {
                @String.Format(T("Blog.FilteredByMonth").Text, Model.PagingFilteringContext.GetParsedMonth().Value.Year, Model.PagingFilteringContext.GetParsedMonth().Value.ToString("MMMM"))
                }
                else
                {
                @T("Blog")
                }
            }
            else
            {
                @String.Format(T("Blog.TaggedWith").Text, Model.PagingFilteringContext.Tag)
            }
        </h1>
    </div>
    <div class="page-body">
        @Html.Widget("mobile_bloglist_page_before_posts")
        <div class="blog-posts">
            @foreach (var item in Model.BlogPosts)
            {
                <div class="post">
                    <a class="post-title" href="@Url.RouteUrl("BlogPost", new { SeName = item.SeName })">
                        @item.Title</a><span class="post-date">-
                            @item.CreatedOn.ToString("D")
                        </span>
                    <div class="post-body">
                        @Html.Raw(item.Body)
                    </div>
                    <div class="tags">
                        @if (item.Tags.Count > 0)
                        {
                            @T("Blog.Tags") 
                            <text>:&nbsp;</text>
                            for (int i = 0; i < item.Tags.Count; i++)
                            {
                                var tag = item.Tags[i];
                            <a href="@Url.RouteUrl("BlogByTag", new { tag = tag })">@tag</a>
                                if (i != item.Tags.Count - 1)
                                {
                            <text>,&nbsp;</text>
                                }
                            }
                        }
                    </div>
                    @if (item.AllowComments)
                    {
                        <a href="@Url.RouteUrl("BlogPost", new { SeName = item.SeName })" class="blog-details">
                            @string.Format(T("Blog.CommentsLink").Text, item.NumberOfComments)
                        </a>
                    }
                    @Html.Widget("mobile_bloglist_page_inside_post")
                </div>
            }
        </div>
        <div class="pager">
            @Html.Pager(Model.PagingFilteringContext).QueryParam("pagenumber")
        </div>
        @Html.Widget("mobile_bloglist_page_after_posts")
    </div>
</div>
